package com.xmut.mall.order.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.xmut.mall.order.entity.ReceiptEntity;
import com.xmut.mall.order.service.ReceiptService;
import com.xmut.mall.order.utils.PageUtils;
import com.xmut.mall.order.utils.R;



/**
 * 
 *
 * @author 1912120131suntingxing
 * @email 1192081604@qq.com
 * @date 2023-02-12 04:07:46
 */
@RestController
@RequestMapping("order/receipt")
public class ReceiptController {
    @Autowired
    private ReceiptService receiptService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = receiptService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		ReceiptEntity receipt = receiptService.getById(id);

        return R.ok().put("receipt", receipt);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody ReceiptEntity receipt){
		receiptService.save(receipt);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody ReceiptEntity receipt){
		receiptService.updateById(receipt);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		receiptService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
